package dl.bukkit.myststus.configuration.imp;


import dl.bukkit.myststus.configuration.SubConfiguration;
import dl.bukkit.myststus.library.ats.Configuration;
import lk.vexview.hud.MinecraftHud;

import java.util.LinkedHashMap;
import java.util.Map;

@Configuration(
        name = "config",
        path = "config.yml"
)
public class Config extends SubConfiguration {

    private static Config inst = null;

    private final Map<MinecraftHud, Boolean> map = new LinkedHashMap<>();

    public Config(String path) {
        super(path);
        inst = this;
    }

    @Override
    public void loadConfig() {
        super.loadConfig();
        for (String hud : getConfigurationSection("MinecraftHud").getKeys(false)) {
            MinecraftHud minecraftHud = getMinecraftHud(hud);
            if (minecraftHud != null) map.put(minecraftHud, getBoolean("MinecraftHud." + hud));
        }
    }

    public Map<MinecraftHud, Boolean> getMinecraftHudMap() {
        return map;
    }

    private MinecraftHud getMinecraftHud(String str) {
        for (MinecraftHud value : MinecraftHud.values()) {
            if (value.name().toLowerCase().equals(str.toLowerCase())) {
                return value;
            }
        }
        return null;
    }

    public static Config getInst() {
        return inst;
    }
}
